#include <iostream>
#include <string.h>
#include <math.h>
using namespace std;

class Point{
public:
    Point(int x, int y)
    :_x(x)
    ,_y(y)
    {   
    
    }
    
    friend class Line;

private:
    double _x;
    double _y;
};

class Color{
public:
    Color(const char * color)
    :_color(new char[strlen(color) + 1]())
    {
        strcpy(_color, color);
    }

    ~Color(){
        if(_color){
            delete [] _color;
            _color = nullptr;
        }
    }

    const char * getColor() const{
        return _color;
    }

private:
    char * _color;
};

class Line{
public:
    Line(int x1, int y1, int x2, int y2)
    :_pt1(x1,y1)
    ,_pt2(x2,y2)
    {

    }

    float distance(){
        return sqrt(pow(_pt1._x - _pt2._x,2) + pow(_pt2._y - _pt2._y,2));
    }

private:
    Point _pt1;
    Point _pt2;
};
class Triangle 
:public Line
    ,public Color
{
public:
    Triangle(int x1,int y1, int x2, int y2, double height, const char * color)
    :Line(x1,y1,x2,y2)
    ,Color(color)
    ,_height(height)
    {

    }
    
    // 周长
    double getPremeter(){
        double line1 = distance();
        double line2 = _height;
        double line3 = sqrt(pow(line1,2) + pow(line2,2));
        return line1 + line2 +line3;
    }
    // 面积
    double getArea(){
        double line1 = distance();
        double line2 = _height;
        return (1.0/2) * line1 * line2;
    }

private:
    double _height;
};
void test(){
    Triangle triangle(0,0,3,0,4,"Blue");
    cout << "颜色" << triangle.getColor() << endl;
    cout << "面积" << triangle.getArea() << endl;
    cout << "周长" << triangle.getPremeter() << endl;
}

int main(int atgc, char * argv[])
{
    test();
    return 0;
}

